package com.ctgu.蓝桥杯真题.B组2020第2场;

import java.io.*;
import java.math.BigInteger;

/**
 * @author: Backdiy
 * @data: 2021/4/6 18:42
 * @desc:
 */

public class A门牌制作 {
    public static void main(String[] args) {
        int ans = 0;
        for (int i = 1; i <= 2020; i++) {
            int a = i % 10;
            int b = i / 10 % 10;
            int c = i / 100 % 10;
            int d = i / 1000 % 10;
            ans = a == 2 ? ans+1 : ans;
            ans = b == 2 ? ans+1 : ans;
            ans = c == 2 ? ans+1 : ans;
            ans = d == 2 ? ans+1 : ans;
        }
        System.out.println(ans);
    }
}

class Input {
    static StreamTokenizer streamTokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter((new OutputStreamWriter(System.out)));

    int nextInt() throws IOException {
        streamTokenizer.nextToken();
        return (int) streamTokenizer.nval;
    }

    double nextDouble() throws IOException {
        streamTokenizer.nextToken();
        return streamTokenizer.nval;
    }

    static long nextLongInt() throws IOException {
        streamTokenizer.nextToken();
        return (long) streamTokenizer.nval;
    }

    String nextLine() throws IOException {
        return bufferedReader.readLine();
    }
}